| Benchmark

> module Bench (main) where

> import qualified Ply
> import qualified Bs
> import qualified Test.BenchPress as BenchPress
> import qualified OptBs
> import Text.Printf (printf)
> import System.IO (hFlush, stdout)

> main :: IO ()
> main = examples >>= mapM_ (\(l,i,a) -> do
>   (cpu,_) <- BenchPress.benchmark i (return ()) (const $ return ()) (const a)
>   printf "%*s: %*.1f\n" (20::Int) l (10::Int) (BenchPress.mean cpu)
>   hFlush stdout)

> run :: Ply.Named Double -> IO ()
> run e =  let Ply.Named (x,ps) = e in
>          let bs = map Bs.ofPly ps :: [Bs.Bs Double] in
>          do (a,b) <- OptBs.infIO bs (map snd x) 0.00005 0
>             a `seq` b `seq` return ()

> examples :: IO [(String, Int, IO ())]
> examples = mapM (\(i,e) -> do
>              c <-  readFile ("examples/" ++ e)
>              let n = read c
>              return (e,i,run n))
>            [ (10, "booth")
>            , (10, "camelback")
>            , (10, "ferguson")
>            , (10, "beale")
>            , (10, "goldstein_price")
>            , (10, "rosenbrock")
>            , ( 1, "colville") 
>            , ( 1, "gamma_pt")
>            ]
